package cn.com.uthink.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * 所有关于字符串的出来以及日期的格式化
 * @author Eric
 *
 */
public class CommonUtils {

	public static final String SECRET_KEY = "sm_app2016_en";
	
	
	public final static SimpleDateFormat DATEFORMAT_YYYY_MM_DD_HH_MM_SS = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
	public final static SimpleDateFormat DATEFORMAT_YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd");
	public final static SimpleDateFormat DATEFORMAT_YYYYMMDDHHMMSS = new SimpleDateFormat("yyyyMMddhhmmss");
	
	/**
	 * 获取RandomID(UUID)
	 * @return
	 */
	public static String randomID(){
		return UUID.randomUUID().toString().replace("-","");
	}

	/**
	 * 获取随机编号(No)
	 * @return
	 */
	public static String serialNo(){
		return DATEFORMAT_YYYYMMDDHHMMSS.format(new Date());
	}
	
	/**
	 * 获取当前时间的String字符串
	 * @return
	 */
	public static String currentTimeStr(){
		return DATEFORMAT_YYYY_MM_DD_HH_MM_SS.format(new Date());
	}
	
	/**
	 * 获取当前时间
	 * @return
	 */
	public static Date currentTime(){
		return new Date();
	}
	
	public static String currentDateStr(){
		return DATEFORMAT_YYYY_MM_DD.format(new Date());
	}
	
	public static void main(String[] args) {
		System.out.println(randomID());
		System.out.println(serialNo());
		System.out.println(currentTimeStr());
		System.out.println(currentTime());
		System.out.println(currentDateStr());
		System.out.println("2ece62e6e09c4c21b74bae46bf4c1ca0".length());
	}

}
